//
//  LGChatTeamNavigation.m
//  HeartDiseaseManage
//
//  Created by 1234 on 2023/3/22.
//

#import "LGChatTeamNavigation.h"

@interface LGChatTeamNavigation()
/**   */
@property (nonatomic , strong)UILabel *titleLabel;
/**   */
@property (nonatomic , strong)UILabel *nameLabel;
/**   */
@property (nonatomic , strong)UILabel *ageLabel;
/**   */
@property (nonatomic , strong)UIImageView *tipView;

@end

@implementation LGChatTeamNavigation


- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = [UIColor whiteColor];
        [self addSubview:self.backBtn];
        [self addSubview:self.titleLabel];
        [self addSubview:self.nameLabel];
        [self addSubview:self.ageLabel];
        [self addSubview:self.tipView];
        [self addSubview:self.patientBtn];
        [self addSubview:self.teamBtn];
        
        [self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self).offset(statusBarHeight+5);
            make.centerX.equalTo(self);
        }];
        [self.ageLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.nameLabel.mas_bottom).offset(1);
            make.centerX.equalTo(self);
        }];
        [self.tipView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.nameLabel.mas_right).offset(5);
            make.centerY.equalTo(self.nameLabel.mas_bottom);
            make.width.height.equalTo(@(12));
        }];
        [self.patientBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.nameLabel).offset(-viewPix(16));
            make.right.equalTo(self.nameLabel).offset(viewPix(20));
            make.top.equalTo(self.nameLabel);
            make.bottom.equalTo(self.ageLabel);
        }];
    }
    return self;
}

-(void)setTitle:(NSString *)title{
    _title = title;
    self.titleLabel.text = title;
}

-(void)setDataDic:(NSDictionary *)dataDic{
    _dataDic = dataDic;
    if([dataDic.allKeys count]>0){
        self.titleLabel.hidden = YES;
        self.nameLabel.hidden = NO;
        self.ageLabel.hidden = NO;
        self.tipView.hidden = NO;
        self.patientBtn.hidden = NO;
        NSDictionary *patientDic = dataDic[@"patient"];
        self.nameLabel.text = LGNSString(patientDic[@"realname"]);
        self.ageLabel.text = [NSString stringWithFormat:@"%@ %@岁",patientDic[@"gender"],patientDic[@"age"]];
    }else{
        self.titleLabel.hidden = NO;
        self.nameLabel.hidden = YES;
        self.ageLabel.hidden = YES;
        self.tipView.hidden = YES;
        self.patientBtn.hidden = YES;
    }
}

-(UIButton *)backBtn{
    if(!_backBtn){
        _backBtn= [UIButton buttonWithType:UIButtonTypeCustom];
        _backBtn.frame = CGRectMake(5, statusBarHeight, 44, 44);
        [_backBtn setImage:kNavBackImage forState:UIControlStateNormal];
        [_backBtn setImage:kNavBackImage forState:UIControlStateHighlighted];
    }
    return _backBtn;
}

-(UILabel *)titleLabel{
    if(!_titleLabel){
        _titleLabel = [UILabel lableWithText:@"" colorString:@"#333333" textFont:LGFontWeight(16, UIFontWeightSemibold) textAlignment:NSTextAlignmentCenter lines:1];
        _titleLabel.frame = CGRectMake(60, statusBarHeight, Screen_W-120, 44);
    }
    return _titleLabel;
}

-(UILabel *)nameLabel{
    if(!_nameLabel){
        _nameLabel = [UILabel lableWithText:@" " colorString:@"#333333" textFont:LGFontWeight(16, UIFontWeightSemibold) textAlignment:NSTextAlignmentCenter lines:1];
        _nameLabel.hidden = YES;
    }
    return _nameLabel;
}

-(UILabel *)ageLabel{
    if(!_ageLabel){
        _ageLabel = [UILabel lableWithText:@" " colorString:@"#999999" textFont:LGFont(13) textAlignment:NSTextAlignmentCenter lines:1];
        _ageLabel.hidden = YES;
    }
    return _ageLabel;
}

-(UIImageView *)tipView{
    if(!_tipView){
        _tipView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"聊天咨询-查看患者"]];
        _tipView.hidden = YES;
    }
    return _tipView;
}

-(UIButton *)patientBtn{
    if(!_patientBtn){
        _patientBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        _patientBtn.hidden = YES;
    }
    return _patientBtn;
}

-(UIButton *)teamBtn{
    if(!_teamBtn){
        _teamBtn = [UIButton buttonWithImage:@"聊天咨询-团队成员" selectImage:@"聊天咨询-团队成员"];
        [_teamBtn setImage:[UIImage imageNamed:@"聊天咨询-团队成员"] forState:UIControlStateHighlighted];
        _teamBtn.frame = CGRectMake(Screen_W-49, statusBarHeight, 44, 44);
        _teamBtn.hidden = YES;
    }
    return _teamBtn;
}


@end
